#ifndef EI_APP_H
#define EI_APP_H

#include <list>

#include <Ogre.h>
#include "include/TextureTest.h"
#include "include/NetManager.h"
#include "include/Gui.h"

using namespace Ogre;

namespace Ei
{


class Scripting;

class App: public FrameListener
{
protected:
	Ei::Scripting * mScripting;
	Ei::Gui * mGui;
	Ei::NetManager * mNetMgr;
	Ogre::SceneManager* mSceneMgr;


        static Ei::App* theApp;
public:
        App(Ei::Scripting* scr, const char * scene_fname);
        virtual ~App();

	// setup
	void setupResources(String dir_name);
	void setupRenderSystem(Ogre::Root * root);
	void setupMainWindow(Ogre::Root * root);
	void setupCamera();
	void setupLook();
	void createAthena();
	void CreateTestTextureObject();
	void loadScene(Ogre::String file_name, Ogre::Root * root);



	// evil static / singleton stuff

	static Ei::Scripting * scripting() { return theApp->mScripting; }
	static Ogre::SceneManager * sceneMgr() { return theApp->mSceneMgr; }
	static Ei::NetManager * netMgr() { return theApp->mNetMgr; }
	static Ei::Gui * gui() { return theApp->mGui; }

/*------( underrefactored )-------------------------------------------------*/
protected:
        RenderWindow* mWindow;

        bool mStatsOn;
        Real blendState;
        int  materialNum;
        Overlay* mDebugOverlay;
        unsigned int mNumScreenShots;

        // i/o XXX to be rewritten, may be with OIS
        //InputReader* mInputDevice;
        Real mTimeUntilNextToggle;

public:
    
        // input processing, navigation etc
        bool processUnbufferedKeyInput(const FrameEvent& evt);
        bool processUnbufferedMouseInput(const FrameEvent& evt);
        void showDebugOverlay(bool show);
        bool frameStarted(const FrameEvent& evt);
        bool frameEnded(const FrameEvent& evt);
        void updateStats(void);
	void postWorldStep();

};

}

#endif // EI_APP_H
